package cn.jkgly.websocket.controller;

import cn.jkgly.utils.AuthUtil;
import cn.jkgly.websocket.server.SocketServer;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;

@Controller
@RequestMapping("/websocket")
public class SocketController {

    /**
     * 根据UUID推送消息，用于微信授权，给指定的网页开发权限。如考试
     * @param msg
     * @param username
     * @return
     */
    @RequestMapping("/sendUUIDmsg")
    @ResponseBody
    public String sendUUIDmsg(String msg, String username){
        SocketServer.sendMessage(msg,username);
        return "success";
    }

    @RequestMapping("/webSocketClient")
    public String socketClient(){
        return "/socketClient";
    }

    @RequestMapping("/webSocketServer")
    public String socketServer(){
        return "/socketServer";
    }

}
